﻿using System.Xml.Linq;
using Game;

namespace SAGhoul
{
	public class TrophyDialog : Dialog
	{
		public ButtonWidget m_okButton;
		public ButtonWidget m_cancelButton;
		public CheckboxWidget m_checkBox;
		public SubsystemSAG m_subsystemSAG;

		public TrophyDialog(SubsystemSAG subsystemSAG)
		{
			m_subsystemSAG = subsystemSAG;
			XElement node = ContentManager.Get<XElement>("Dialogs/TrophyDialog");
			LoadContents(this, node);
			m_okButton = Children.Find<ButtonWidget>("OKButton");
			m_cancelButton = Children.Find<ButtonWidget>("CancelButton");
			m_checkBox = Children.Find<CheckboxWidget>("Checkbox");
			m_checkBox.IsChecked = m_subsystemSAG.SAGEnable;
		}

		public override void Update()
		{
			if (m_okButton.IsClicked)
			{
				Dismiss(m_checkBox.IsChecked);
			}
			if (Input.Cancel || m_cancelButton.IsClicked)
			{
				Dismiss(null);
			}
		}

		public void Dismiss(bool? flag)
		{
			if (flag.HasValue)
			{
				m_subsystemSAG.SAGEnable = flag.Value;
			}
			DialogsManager.HideDialog(this);
		}

	}
}
